package com.xtaller.test.anync;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @version V1.0
 * @author: Taller
 * @date: 2019-08-22
 * @Description:
 */
@Component
public class TimeTask {
    private Logger logger = LoggerFactory.getLogger(TimeTask.class);

    private int initialDelayCount = 1;
    @Scheduled(initialDelay = 1000, fixedRate = 500000)   //initialDelay = 1000表示延迟1000ms执行第一次任务
    public void testInitialDelay() {
        logger.info("===initialDelay: 第{}次执行方法", initialDelayCount++);
    }

//    @Scheduled(cron = "0/10 * * * * ?")
//    public void run() {
//        System.out.println(Thread.currentThread().getName()+"=====>>>>>使用cron  {}"+(System.currentTimeMillis()/1000));
//    }
}
